package com.mall.service.order.controller;

import com.mall.commons.common.CommonResult;
import com.mall.model.domain.OmsOrderReturnApply;
import com.mall.model.dto.ReturnApplyDto;
import com.mall.model.dto.StatusParam;
import com.mall.model.vo.PageResult;
import com.mall.model.vo.ReturnPage;
import com.mall.service.order.service.OmsOrderReturnApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {
    @Autowired
    private OmsOrderReturnApplyService omsOrderReturnApplyService;

    //批量退货申请
    @PostMapping("/delete")
    public CommonResult returnApply(@RequestParam List<Integer> ids) {
        omsOrderReturnApplyService.delete(ids);
        return CommonResult.success("删除成功");
    }
//分页查询退货申请
    @GetMapping("/list")
    public CommonResult list( ReturnApplyDto returnApplyDto){
    PageResult pageResult = omsOrderReturnApplyService.page(returnApplyDto);
     return CommonResult.success(pageResult);
    }
  //  修改退货申请状态
    @PostMapping("/update/status/{id}")
    public CommonResult update(@PathVariable Integer id,@RequestBody StatusParam statusParam){
        omsOrderReturnApplyService.update(id,statusParam);
        return CommonResult.success("修改成功");
    }
//获取退货详情
    @GetMapping("/{id}")
    public CommonResult get(@PathVariable Integer id){
        OmsOrderReturnApply omsOrderReturnApply = omsOrderReturnApplyService.get(id);
        return CommonResult.success(omsOrderReturnApply);
    }

}
